home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / SAT 2.4.0 / SAT / Add-ons / Storage / ScoresStubs.p < prev    next >
Encoding:
Text File  |  1996-06-09  |  3.5 KB  |  131 lines  |  [TEXT/PJMM]

  1. {*** This copy of ScoresStubs modified for <your project here>! ***}
  2.  
  3. {================================================}
  4. {============= Score handling and display ==============}
  5. {================================================}
  6.  
  7. {ScoresStubs is the non-reusable part of the Scores unit in the SAT Add-ons.}
  8. {You should make a copy for your project and modify it to suit your needs.}
  9. {You can change the limits (if any), how scores are drawn etc.}
  10.  
  11.  
  12. unit ScoresStubs;
  13. interface
  14.  
  15. {uses SAT, your globals… as necessary}
  16.     uses
  17.         SAT;
  18.  
  19.     const
  20.         kStringSize = 20;
  21.         kListLength = 10;
  22.         kFirstLimit = 100;    {Limit for special event, i.e. new life}
  23.         kAskHighDlog = 128;    {Id of DLOG resource for asking for name at high score}
  24.         kMargin = 3;            {Margin between the text fields in the high score list}
  25.     var
  26.         gNextLimit: Longint;
  27.  
  28.     procedure DoLimit;                                        {Extra life etc.}
  29.  
  30.     procedure DrawScore (score: Longint);                {Draw score offscreen}
  31.     procedure DrawScoreImmediate (score: Longint);    {Draw score immediately}
  32.  
  33. implementation
  34.  
  35. {DoLimit is called whenever the current limit is reached. Here you should add new lives,}
  36. {show that in any way you see fit, and increase gNextLimit to the next limit! Set gNextLimit}
  37. {to 0 if there are no more limits.}
  38.     procedure DoLimit;
  39.     begin
  40. {lives := lives + 1;}
  41.         gNextLimit := gNextLimit * 2;
  42. {SATSoundPlay(klounkSndH, 15, true);}
  43.     end;
  44.  
  45. {InternalDrawScore draws the score (and optionally more) at the appropriate place.}
  46. {Rewrite this for each program!}
  47.  
  48.     function InternalDrawScore (score: Longint): Rect;
  49.         var
  50.             s: str255;
  51.             r: Rect;
  52.             pn: PenState;
  53.     begin
  54.         GetPenState(pn);
  55.         BackColor(blackColor);
  56.         if gSAT.initDepth > 1 then
  57.             ForeColor(redColor)
  58.         else
  59.             ForeColor(whiteColor);
  60.  
  61. {Set and erase the rectangle in which the score (etc) should be drawn.}
  62.         SetRect(r, 0, 0, gSAT.OffSizeH, 20);
  63.         EraseRect(r);
  64.  
  65. {Draw the score!}
  66.  
  67.         NumToString(score, s);
  68.         MoveTo(r.left + 20, r.top + 15);
  69.         DrawString('Score: ');
  70.         MoveTo(r.left + 70, r.top + 15);
  71.         DrawString(s);
  72.  
  73. {Other things you may want to draw include lives, level etc.}
  74.  
  75. {NumToString(lives, s);}
  76. {MoveTo(r.left + 200, r.top + 15);}
  77. {DrawString('Lives: ');}
  78. {MoveTo(r.left + 240, r.top + 15);}
  79. {DrawString(s);}
  80.  
  81. {NumToString(level, s);}
  82. {MoveTo(r.left + 400, r.top + 15);}
  83. {DrawString('Level: ');}
  84. {MoveTo(r.left + 450, r.top + 15);}
  85. {DrawString(s);}
  86.  
  87.         BackColor(whiteColor);
  88.         ForeColor(blackColor);
  89.         SetPenState(pn);
  90.         InternalDrawScore := r;
  91.     end; {InternalDrawScore}
  92.  
  93. {DrawScore and DrawScoreImmediate may be useable as they are, as long as you draw}
  94. {your score in gSAT.backScreen. If you don't, you have to modify them.}
  95.  
  96. {DrawScore draws the score in gSAT.backScreen and asks SAT to update in the next}
  97. {turn though SATRun.}
  98.     procedure DrawScore (score: Longint);
  99.         var
  100.             s: Str255;
  101.             r: Rect;
  102.             tmpPort: SATPort;
  103.     begin
  104.         SATGetPort(tmpPort);
  105.         SATSetPortBackScreen;
  106.         r := InternalDrawScore(score);
  107.         SATBackChanged(r); {Nya sättet att dunka saker på skärmen!}
  108.         SATSetPort(tmpPort);
  109.     end; {DrawScore}
  110.  
  111. {DrawScoreImmediate draws the score in gSAT.backScreen and immediately copies}
  112. {it to screen.}
  113.     procedure DrawScoreImmediate (score: longint);
  114.         var
  115.             s: str255;
  116.             r: Rect;
  117.             tmpPort: SATPort;
  118.     begin
  119.         SATGetPort(tmpPort);
  120.         SATSetPortBackScreen;
  121.         r := InternalDrawScore(score);
  122.         SATSetPortScreen;
  123.         CopyBits(gSAT.backscreen.port^.portbits, gSAT.wind.port^.portBits, r, r, srcCopy, nil);
  124.         SATSetPortOffscreen;
  125.         CopyBits(gSAT.backscreen.port^.portbits, gSAT.offscreen.port^.portBits, r, r, srcCopy, nil);
  126.         SATSetPort(tmpPort);
  127.     end; {DrawScoreImmediate}
  128.  
  129.  
  130.  
  131. end.